s1 = {10, 20, 30, 40, 50}

# remove(): 删除指定数据，如果数据不存在报错
# s1.remove(10)
# print(s1) #{50, 20, 40, 30}

"""
Traceback (most recent call last):
  File "D:\program files\JetBrains\PyCharm 2025.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1570, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\program files\JetBrains\PyCharm 2025.1.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "E:\文件资料\python-study\Code\04-数据序列\05-集合\hm_03_集合常见操作之删除数据.py", line 7, in <module>
    s1.remove(100)  # 报错
    ^^^^^^^^^^^^^^
KeyError: 100
python-BaseException
"""
# s1.remove(100)  # 报错
# print(s1)

# discard()：删除指定数据，如果数据不存在不报错
# s1.discard(10)
# print(s1) #{50, 20, 40, 30}

s1.discard(100)
print(s1)  # {50, 20, 40, 10, 30}

# pop(): 随机删除某个数据，并返回这个数据
del_num = s1.pop()
"""
50
{20, 40, 10, 30}
"""
print(del_num)
print(s1)
